package com.example.firstprojectnew.config;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: lihua
 * @Date: 2025/5/7 23:19
 * @Version: v1.0.0
 * @Description:
 **/

public class QuartzConfig {

    @Bean
    public JobDetail myJobDetail(){
        return JobBuilder.newJob(QuzrtzTest.class)
                .withIdentity("test")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger myTrigger(){
        CronScheduleBuilder builder = CronScheduleBuilder.cronSchedule("0/5 * * * * ?");
        return TriggerBuilder.newTrigger()
                .forJob(myJobDetail())
                .withIdentity("testTrigger")
                .withSchedule(builder)
                .build();
    }

}
